package com.fmy.jurisdiction.config.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName SpringContext
 * @Description TODO SpringContext 类
 * @createTime 2019/9/16 10:59
 */
@Component
public class SpringContext implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public static ApplicationContext get() {
        if (applicationContext == null) throw new IllegalArgumentException("applicationContext 未注入");
        return applicationContext;
    }
}
